package com.huge.simple.common.exception;


import com.huge.simple.common.response.HttpCode;
import com.huge.simple.common.response.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 统一异常处理
 * @author jihu
 * date 2022-03-28
 */
@Slf4j
@RestControllerAdvice
public class SimpleExceptionHandler {

    @ExceptionHandler(BusinessException.class)
    public Result<?> handleBusinessException(BusinessException businessException){
        log.error("业务异常！",businessException);
        return Result.error(businessException.getMessage());
    }


    @ExceptionHandler(Exception.class)
    public Result<?> handleException(Exception exception){
        log.error("系统异常！",exception);
        return Result.error("系统异常,请联系管理员！");
    }

}
